package lab01;

import java.util.Scanner;//导入Scanner类

public class Test06 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);//读取用户输入
        System.out.println("Please enter garde:");
        int num = sc.nextInt();//读入一个int
        Ifelse(num);
        Switch(num);
    }

    //用if-else实现
    public static void Ifelse(int num) {
        if (num == 1) {
            System.out.println("不合格");
        } else if (num == 2) {
            System.out.println("及格");
        } else if (num == 3) {
            System.out.println("中等");
        } else if (num == 4) {
            System.out.println("良好");
        } else if (num == 5) {
            System.out.println("优秀");
        } else {
            System.out.println("输入错误！");
        }
    }

    //用switch实现
    public static void Switch(int num) {

        switch (num) {
            case 1:
                System.out.println("不合格");
                break;
            case 2:
                System.out.println("及格");
                break;
            case 3:
                System.out.println("中等");
                break;
            case 4:
                System.out.println("良好");
                break;
            case 5:
                System.out.println("优秀");
                break;
            default:
                System.out.println("输入错误！");
        }
    }
}
